package com.zephyr.vchcenter.bpm.action;

import org.apache.log4j.Logger;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class TallyFailedAuditVerifyAction extends TaskAction{
	
	private static Logger log = Logger.getLogger(TallyFailedAuditVerifyAction.class);
	@Override
	public void perform(ServiceContext sc) throws ServiceException,
			ParameterException {
		String vchsid=(String)sc.getInputParameterValue("vchsid");
		String result=(String)sc.getInputParameterValue("result");
		String agreement = (String) sc.getInputParameterValue("agreement");
		IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
        Voucher voucher=(Voucher)dao.findById("Voucher", vchsid);
		log.debug("进入TallyFailedAuditVerifyAction===============");
//		log.debug("result========="+result);
		
		if (Integer.parseInt(agreement) == 1) {
			voucher.setRestally("4");
			log.debug(result+"--------------->");
			if("0".equals(result)){
				voucher.setTallytype("2");
				
			}else{
				voucher.setTallytype("1");
			}
		}else if(Integer.parseInt(agreement) == 0){
			voucher.setRestally(null);
			voucher.setRestally("2");
		}
		dao.saveOrUpdate(voucher);
//		sc.setOutputParameterValue("accno", accno);
//		sc.setOutputParameterValue("vchno", vchno);
//		sc.setOutputParameterValue("amount", amount);
//		sc.setOutputParameterValue("result", Integer.parseInt(result));
//		sc.setOutputParameterValue("agreement", Integer.parseInt(agreement));
	}

	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {
		
	}

}
